import request from '@/utils/request'
import { parseStrEmpty } from '@/utils/ruoyi'
// 查询用户列表
export function listUser(query) {
  return request({
    url: '/user-center/web/user/page',
    method: 'post',
    data: query
  })
}

// 查询用户列表
export function listSysUser(query) {
  return request({
    url: '/user-center/sysuser/page',
    method: 'post',
    data: query
  })
}

// 查询用户信息详细
export function getUser(userId) {
  return request({
    url: '/user-center/sysuser/' + userId,
    method: 'get'
  })
}


// 用户密码修改 需要旧密码版本 2023-8-18 yg
// data: { userId, xmm, jmm}
export function updatePassword(data) {
  return request({
    url: '/user-center/sysuser/updatePwd',
    method: 'post',
    data
  })
}


// 用户密码重置
export function resetUserPwd(userId, userPwd) {
  const data = {
    userId,
    userPwd
  }
  return request({
    url: '/user-center/sysuser/resetPwd',
    method: 'post',
    data: data
  })
}

// 修改用户信息
export function updateUser(data) {
  return request({
    url: '/user-center/sysuser/update',
    method: 'post',
    data: data
  })
}

// 新增用户信息
export function addUser(data) {
  return request({
    url: '/user-center/sysuser/insert',
    method: 'post',
    data: data
  })
}

// 删除用户信息
export function delUser(userId) {
  return request({
    url: '/user-center/sysuser/' + userId,
    method: 'delete'
  })
}

// 查询用户详细
// export function getUser(userId) {
//   return request({
//     url: '/user-center/common/user/list' + parseStrEmpty(userId),
//     method: 'get'
//   })
// }

// 查询部门下拉树结构
export function deptTreeSelect() {
  return request({
    url: '/user-center/dept/list',
    method: 'post'
  })
}

// 查询机构下拉树结构
export function jgTreeSelect(data) {
  return request({
    url: '/user-center/jggl/treelist',
    method: 'post',
    data: data
  })
}

